# ~*~ coding: utf-8 ~*~
import time
from apps.common.dbbase import BaseModel
from apps.common.utils import generate_uuid
from apps.extensions import db

__all__ = ['SFTPLog']


class SFTPLog(BaseModel):
    __tablename__ = 'terminal_sftp_log'

    id = db.Column(db.CHAR(36), default=generate_uuid,  primary_key=True)
    user = db.Column(db.VARCHAR(128))
    asset = db.Column(db.VARCHAR(1024))
    system_user = db.Column(db.VARCHAR(128))
    remote_addr = db.Column(db.VARCHAR(126), nullable=True)
    operate = db.Column(db.VARCHAR(126), nullable=True)
    filename = db.Column(db.VARCHAR(1024), nullable=True)
    is_success = db.Column(db.Boolean, default=False)
    create_time = db.Column(db.INT, default=time.time)

    def __str__(self):
        return "<SFTPLog: {}>".format(self.id)


